<?php
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/client/GameClient.php';

try {
    // 创建客户端实例
    $client = new GameClient('localhost', 2346);
    
    // 从您的系统获取token
    $token = "6be8b21fa50ccf9833f24ae8172a0321";
    
    // 连接到服务器并认证
    $client->connect($token);
    
    // 创建房间
    $response = $client->createRoom();
    $data = json_decode($response, true);
    
    if (isset($data['error'])) {
        throw new Exception($data['message'], $data['code']);
    }
    
    $roomId = $data['roomId'];
    echo "Created room: " . $roomId . "\n";
    
    // 加入房间
    $client->joinRoom($roomId);
    
    // 准备
    $client->ready();
    
    // 游戏动作示例
    $client->sendGameAction([
        'type' => 'play',
        'data' => ['card' => 'A♠']
    ]);
    
    // 关闭连接
    $client->close();
    
} catch (Exception $e) {
    echo "Error ({$e->getCode()}): " . $e->getMessage() . "\n";
} 